//
//  ProtocolViewController.swift
//  YLH
//
//  Created by qinjiangtao on 2024/1/22.
//

import UIKit
import WebKit

class ProtocolViewController: QIBaseViewController {
    
    var titleStr = ""

    override func viewDidLoad() {
        super.viewDidLoad()
        title = titleStr

        getData()
    }
    
    
    private func getData() {
        var urlStr = ""
        if titleStr == "用户协议" {
            urlStr = "/Config/getUserAgreement"
        } else {
            urlStr = "/Config/getPrivacyPolicy"
        }
        
        QINetworkManager.requestJson(urlStr: urlStr, method: .get, parameters: [:]) { json in
            print(json)
            self.addWebView(webStr: json.stringValue)
        }
        
    }
    
    private func addWebView(webStr: String) {
        let str1 = """
        <html>
            <head>
                <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'>
            <head>
            <body>
                \(webStr)
            <body>
        <html>
        """
        let webView = WKWebView(frame: CGRect(x: 0, y: NAV_HEIGHT, width: SCREEN_WIDTH, height: SCREEN_HEIGHT))
        webView.loadHTMLString(str1, baseURL: nil)
        self.view.addSubview(webView)
    }

    
    

}
